<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>组件简的多层传递</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <parent :title="title" :img-src="imgSrc"></parent>
    </div>
    <template id="img">
    <img :src="imgSrc" alt="图片">
  </template>
    <template id="title">
    <h1>{{title}}</h1>
  </template>

    <template id="parent">
    <div>
        <app-img :img-src="imgSrc"></app-img>
        <app-title :title="title"></app-title>
    </div>
    
    
  </template>

    <script>
        let Img = Vue.extend({
            template: '#img',
            props: ["imgSrc"]
        });
        let Title = Vue.extend({
            template: "#title",
            props: ['title']
        });

        Vue.component("parent", {
            components: {
                "app-img": Img,
                "app-title": Title

            },
            template: "#parent",
            props: ["title", "imgSrc"]
        })
        new Vue({
            el: '#app',
            data: {
                title: "ldsfjsjd",
                imgSrc: "../../images/14.jpg"
            }
        })
    </script>


</body>

</html>